<template>
    <div class="about">
        <h2>$emit与$on方法组件传值</h2>
        <h1>This is an about page</h1>
        <input type="text" name="" placeholder="修改我的数据" v-model='a'>
        <input type="button" value='把About数据传给home' @click='send' />
        <span>接收home组件的数据为：{{a}}</span>
    </div>
</template>
<script>
import bus from '../bus.js'
export default {
    name: 'About',
    components: {},
    data() {
        return {
            a: 'about'
        }
    },
    methods: {
        send() {
            bus.$emit('b-msg', this.a);
        }
    },
    mounted() {
        // 接收A中的数据
        // $on('事件名',fn(a))
        console.log('mounted')
        bus.$on('a-msg', (a) => {
            this.a = a;
        });
    }

}
</script>
<style scoped>
.about {
    border: 1px solid orange;
    background-color: yellow;
}
</style>
